package com.tanhua.app.service;

import com.tanhua.api.mongdb.PublishApi;
import com.tanhua.domain.UserHolder;
import com.tanhua.domain.mogo.Publish;
import org.apache.dubbo.config.annotation.Reference;
import org.apache.rocketmq.spring.core.RocketMQTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;

@Service
public class BigDataService {

    @Autowired
    private RocketMQTemplate rocketMQTemplate;

    @Reference
    private PublishApi publishApi;

    //望mq中存信息
    public void toMq(int type, String publishId) {
        Long userId = UserHolder.findUser().getId();


        Publish publish = publishApi.findById(publishId);
        HashMap map = new HashMap();
        map.put("userId",userId);
        map.put("type",type);
        map.put("pid",publish.getPid());

        rocketMQTemplate.convertAndSend("tanhua-bigdata",map);
    }

    public void toMqByVideo(int i, Object o) {
    }
}
